import Vue from 'vue'
import iView from 'iview';
import VCharts from 'v-charts'
// 地图
import BaiduMap from 'vue-baidu-map'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import '@/assets/css/iconfont/1.0.0/index.css' /* icofont*/
// css
import 'normalize.css/normalize.css'// A modern alternative to CSS resets
import '@/styles/index.scss' // global css
// 右键菜单
import contentmenu from 'v-contextmenu'
import 'v-contextmenu/dist/index.css'
import './errorLog'// error log
// font-awesome
import '@/assets/library/font-awesome-4.7.0/css/font-awesome.min.css'
import App from './App'
import router from './router'
import store from './store'
// Internationalization
import i18n from './lang'
import {global} from '@/global/global'
import {loadStyle,closePageTo,isEmptyStr,isNotEmptyStr} from './utils/util'
import {iconfontUrl,iconfontVersion} from '@/config/env'
import '@/icons' // icon
import '@/permission' // permission control
import * as filters from './filters' // global filters
// register global utility filters.
import { cofirmBox, successBox, failBox, warnBox } from '@/utils/messageBox'
// 数据转换
import dataMethod from '@/utils/datasformat';

Vue.prototype.cofirmBox = cofirmBox // 不带任何符号
Vue.prototype.successBox = successBox // 带对勾符号
Vue.prototype.failBox = failBox // 带叉号符号
Vue.prototype.warnBox = warnBox // 带感叹符号
Vue.use(dataMethod)
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
Vue.use(iView);
Vue.use(VCharts)
Vue.use(contentmenu)
// Vue.use(ElementUI, { locale })
Vue.use(ElementUI)
iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrl.replace('$key', ele))
})
Vue.prototype.closePageTo = closePageTo // 关闭当前页面跳转至指定页面
Vue.prototype.isEmptyStr = isEmptyStr // 判断字符串为空
Vue.prototype.isNotEmptyStr = isNotEmptyStr // 判断字符串不为空
Vue.use(ElementUI, {
  size: 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})
// 地图
Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: 'oW2UEhdth2tRbEE4FUpF9E5YVDCIPYih'
})
// 加载用户主题
if (localStorage.getItem('themeValue')) {
  global.changeTheme(localStorage.getItem('themeValue'))
} else {
  global.changeTheme('default')
}
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  // template: '<App/>',
  // components: { App }
  render: h => h(App)
})
